/**
 * Copyright (C) 2016 Eshore Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.eshore.thrpc.test.demo.prop;

import com.eshore.thrpc.main.Server;
import com.eshore.thrpc.test.EchoServiceImpl;

/**
 * The demo for server by properties file.
 * <p>
 * 
 * @author : zhouzhixiang
 * @date : 2015-8-17
 */
public class PropServerDemo {
	/** 配置文件路径，配置说明参考 {@link Server#Server(String[] , Object )} */
	private static final String CONFIG_FILE_PATH = "classpath:demo/demo-server.properties";

	/** 是否保持启动 */
	private static boolean running = true;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String[] configs = new String[] { CONFIG_FILE_PATH };
		EchoServiceImpl impl = new EchoServiceImpl();

		try {
			long start = System.currentTimeMillis();
			Server server = new Server(configs, impl);
			server.start(); // 启动服务，非阻塞
			long end = System.currentTimeMillis();
			System.out.println("start time-consuming:" + (end - start));
			synchronized (PropServerDemo.class) {
				while (running) {
					try {
						PropServerDemo.class.wait();
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
